package com.iplant.basic.service.po.fmc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.basic.service.basicenum.bfc.FMCShiftType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * @author  xiutou
 * 班次设置
 * 可设置到工厂、车间、工区、工位上
 * 最起码需要设置工厂的班次 可以前端自动生成工厂的班次配置
 * 底层没查询到查上层并返回给前端
 */
@DBBasePO(TableName = "fmc_shift", Code = false, Name = false,
        CheckName = {"ShiftType,StationID,WorkAreaID,WorkshopID,FactoryID"})
public class FMCShift extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    public String ShiftName = "";

    @DBCondition
    @DBField
    public int ShiftType = 0; // 1--3：早、中、晚;

    @DBCondition
    @DBField
    public int StationID = 0;
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "s1", MainTableField = "StationID")
    public String StationName = "";

    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "s1", MainTableField = "StationID")
    public String StationCode = "";


    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "w2", MainTableField = "WorkAreaID")
    public String WorkAreaName = "";

    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "w2", MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";


    @DBCondition
    @DBField
    public int WorkshopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "w1", JoinIndex = 2, MainTableField = "WorkshopID")
    public String WorkshopName = "";
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "w1", JoinIndex = 2, MainTableField = "WorkshopID")
    public String WorkshopCode = "";

    @DBCondition
    @DBField
    public int FactoryID = 0;

    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "f1", JoinIndex = 3, MainTableField = "FactoryID")
    public String FactoryCode = "";

    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "f1", JoinIndex = 3, MainTableField = "FactoryID")
    public String FactoryName = "";

    @DBField
    public Calendar StartTime = Calendar.getInstance(); // 开始时刻

    @DBField
    public Calendar EndTime = Calendar.getInstance(); // 结束时刻

    @DBField
    public int Minutes = 0; // 总时长;

    @DBField
    public int WorkMinutes = 0; // 工作时长;

    @DBField
    public int IdleMinutes = 0; // 休息时长;

    /**
     * 是否根据日历自动生成  默认是
     *  特殊工位与是否休息无关 可以设置为0 即永不休息，
     *  但是可以在计划员在工位排程时将计划调整延后
     */
    @DBCondition
    @DBField
    public int HolidayEnable=1;


    public List<FMCTimeZone> TimeZoneList=new ArrayList<>();


    @JsonProperty("Name")
    public String getShiftName() {

        ShiftName = FMCShiftType.getEnumType(ShiftType).getLabel();

        return ShiftName;
    }


    public void setShiftName(String shiftName) {
        ShiftName = shiftName;
    }

    @JsonProperty("ShiftType")
    public int getShiftType() {
        return ShiftType;
    }

    public void setShiftType(int shiftType) {
        ShiftType = shiftType;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("WorkshopID")
    public int getWorkshopID() {
        return WorkshopID;
    }

    public void setWorkshopID(int workshopID) {
        WorkshopID = workshopID;
    }

    @JsonProperty("WorkshopName")
    public String getWorkshopName() {
        return WorkshopName;
    }

    public void setWorkshopName(String workshopName) {
        WorkshopName = workshopName;
    }

    @JsonProperty("WorkshopCode")
    public String getWorkshopCode() {
        return WorkshopCode;
    }

    public void setWorkshopCode(String workshopCode) {
        WorkshopCode = workshopCode;
    }

    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("StartTime")
    public Calendar getStartTime() {
        return StartTime;
    }

    public void setStartTime(Calendar startTime) {
        StartTime = startTime;
    }

    @JsonProperty("EndTime")
    public Calendar getEndTime() {
        return EndTime;
    }

    public void setEndTime(Calendar endTime) {
        EndTime = endTime;
    }

    @JsonProperty("Minutes")
    public int getMinutes() {
        return Minutes;
    }

    public void setMinutes(int minutes) {
        Minutes = minutes;
    }

    @JsonProperty("WorkMinutes")
    public int getWorkMinutes() {
        return WorkMinutes;
    }

    public void setWorkMinutes(int workMinutes) {
        WorkMinutes = workMinutes;
    }

    @JsonProperty("IdleMinutes")
    public int getIdleMinutes() {
        return IdleMinutes;
    }

    public void setIdleMinutes(int idleMinutes) {
        IdleMinutes = idleMinutes;
    }
    @JsonProperty("HolidayEnable")
    public int getHolidayEnable() {
        return HolidayEnable;
    }

    public void setHolidayEnable(int holidayEnable) {
        HolidayEnable = holidayEnable;
    }
}
